package com.fetch.listener;

import java.awt.Color;

import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class ProgressBarChangeListener implements ChangeListener {
    private JProgressBar progressBar;
    private JLabel percentLabel;
    
    public ProgressBarChangeListener(JProgressBar progressBar, JLabel percentLabel) {
        super();
        this.progressBar = progressBar;
        this.percentLabel = percentLabel;
    }

    @Override
    public void stateChanged(ChangeEvent e) {
        if (e.getSource() == progressBar) {
               percentLabel.setText(progressBar.getValue() + "%");
               percentLabel.setForeground(Color.blue);
           }
    }
}
